package com.auxgroup.hr.front.service.personnal.impl;

import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import com.auxgroup.hr.front.dao.domain.PsCJcxxTbl;
import com.auxgroup.hr.front.dao.domain.PsCPersonalInfoClass;
import com.auxgroup.hr.front.dao.repository.PsCJcxxTblRepository;
import com.auxgroup.hr.front.service.personnal.JcxxTblService;

/** 
 * @author wangchangyun
 * @version 创建时间：180523 
 * 奖惩情况service
 */
@Service("jcxxTblService")
public class JcxxTblServiceImpl implements JcxxTblService {
	private static final Logger logger = LoggerFactory.getLogger(JcxxTblServiceImpl.class);
	
	@Autowired
	private PsCJcxxTblRepository PsCJcxxTblRepository;


	@Override
	public PsCJcxxTbl getJcxxTbl(PsCPersonalInfoClass personalInfo) {
		return PsCJcxxTblRepository.findOne(personalInfo);
	}


	@Override
	public PsCJcxxTbl save(PsCJcxxTbl JcxxTbl) {
		return PsCJcxxTblRepository.save(JcxxTbl);
	}


	@Override
	public Boolean delete(PsCPersonalInfoClass personalInfo) {
		try {
			PsCJcxxTblRepository.delete(personalInfo);
		} catch (Exception e) {
			logger.error("delete JcxxTbl error: personalInfo={}",personalInfo,e);
			return false;
		}
		return true;
	}
	
	
	@Override
	public List<PsCJcxxTbl> getAll(String emplId) {
		PsCJcxxTbl JcxxTbl = new PsCJcxxTbl();
		JcxxTbl.setEmplid(emplId);
		return PsCJcxxTblRepository.findAll(Example.of(JcxxTbl),new Sort(Sort.Direction.DESC,"cDate"));
	}


	
	
	
}
